/***************************************************************************
 创建者：华磊
 开始时间：         : 2020.12.13
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   等待指令属性编辑视窗
*                                                                         *
 ***************************************************************************/
#include "waitcommandview.h"
#include "ui_waitcommandview.h"
#include "../../programView/programview.h"


WaitCommandView::WaitCommandView(int styleId,QWidget *parent):
    QWidget(parent),
    ui(new Ui::WaitCommandView)
{
    ui->setupUi(this);
    initialDisplayStyle(styleId);
}

void WaitCommandView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->forward_Btn->setGeometry(10,350,70,40);
        ui->save_Btn->setGeometry(360,350,70,40);
        break;
    default:
        break;
    }
}

void WaitCommandView::updateView()
{
    // QString textToShow="";
    //textToShow=QString("%1").arg(batteryElectricQuantity, 0, 'g',4);
    ui->LBL_lineEdit->setText(timeOutLabel);
    ui->timeOutSecond->setText(QString::number(waitMaxTime));
    ui->regRIndex_lineEdit->setText(QString::number(registerIndex));
    ui->note_lineEdit->setText(note);
}

void WaitCommandView::getInput()
{
    //
    timeOutLabel = ui->LBL_lineEdit->text();
    waitMaxTime = ui->timeOutSecond->text().toInt();
    registerIndex = ui->regRIndex_lineEdit->text().toInt();
    note = ui->note_lineEdit->text();
}
void WaitCommandView::initData()
{
    note ="";
    timeOutLabel = "0";
    waitMaxTime = 0;
    registerIndex = 0;
}

void WaitCommandView::changeLanguage(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/checkBatteryInstructionView.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }
    ui->retranslateUi(this);
}

void WaitCommandView::on_clearNote_Btn_clicked()
{
    ui->note_lineEdit->clear();
    emit clearNote();
}

void WaitCommandView::on_forward_Btn_clicked()
{
    this->close();
    programView->instructionListFlag = 0;
    programView->editInstructionViewShowOrHide();
}

void WaitCommandView::on_save_Btn_clicked()
{
    finishedEditInstructionHandle();
}
void WaitCommandView::finishedEditInstruction_slot()
{
    finishedEditInstructionHandle();
}
void WaitCommandView::finishedEditInstructionHandle()
{
    getInput();
    emit finishEditInstructionSignal();
    emit saveInstructionSignal(waitCommandInstruction);
}

